package team526.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import team526.dao.TagDao;
import team526.entity.Tag;

import java.util.List;

/**
 * #Date 2021/9/28 - 22:45
 *
 * @author 王铭 20181620310021
 */
@RestController
@RequestMapping("tag")
@CrossOrigin(origins = {"http://localhost:8080","http://192.168.31.212:8080","http://127.0.0.1:8080","http://video.team526:8080"}, allowCredentials = "true")
public class TagController {

    @Autowired
    TagDao tagDao;

    @GetMapping("get_sub_tags/{tag_id}")
    List<Tag> getSubTags(@PathVariable Integer tag_id) {
        return tagDao.getSubTags(tag_id);
    }

    @GetMapping("get_main_tags")
    List<Tag> getMainTags() {
        return tagDao.getSubTags(0);
    }

    @GetMapping("searchTagsName/{tag_name}")
    List<Tag> searchTagsName(@PathVariable String tag_name) {
        return tagDao.searchTagsName(tag_name);
    }


    @GetMapping("getTagById/{tag_id}")
    Tag getTagById(@PathVariable Integer tag_id) {
        return tagDao.getById(tag_id);
    }


}
